<template>
  <div class="newsInfo">
    <!-- 标题 -->
    <h1>{{infos.title}}</h1>
    <!-- 子标题 -->
    <p>
      <span>发表时间：{{infos.addTime}}</span>
      <span>点击{{infos.click}}次</span>
    </p>
    <hr />
    <!-- 内容 -->
    <div class="content">{{infos.info}}</div>
    <!-- 评论子组件 -->
    <comment></comment>
  </div>
</template>

<style lang="less" scoped>
.newsInfo {
  padding: 0 5px;
  h1 {
    font-size: 16px;
    color: red;
    text-align: center;
    margin: 10px 0;
  }
  p {
    font-size: 12px;
    color: #226aff;
    display: flex;
    justify-content: space-between;
  }
  .content {
    font-size: 14px;
    color: #666;
    text-indent: 2em;
  }
}
</style>
<script>
import comment from "../subcomponents/comment.vue";
export default {
  data() {
    return {
      id: this.$route.params.id,
      infos: ""
    };
  },
  created() {
    this.getNewsInfo();
  },
  methods: {
    getNewsInfo() {
      this.$http.get("getnewsList/" + this.id).then(res => {
        this.infos = res.body;
      });
    }
  },
  components: {
    comment
  }
};
</script>